package com.bj58.mis.apm.server.statistics.conf;

import com.bj58.mis.apm.server.statistics.auth.AuthInterceptor;
import com.bj58.mis.apm.server.statistics.mock.interceptor.MockInterceptor;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.Ordered;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * @author: zhangfx
 * @create: 2018-07-04 10:38
 **/
@Configuration
@ConditionalOnProperty(name = "roc.auth.enable", havingValue = "true")
public class AuthInterceptorsConfig implements WebMvcConfigurer {
    @Bean
    public AuthInterceptor authInterceptor(){
        return new AuthInterceptor();
    }

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(authInterceptor()).addPathPatterns("/**").order(Ordered.HIGHEST_PRECEDENCE);
    }
}
